﻿using Shake.Domain.Infrastructures;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Shake.Framework.Models
{
    public class PaginationContent : IContent
    {
        /// <summary>
        /// 分页数 = pageSize
        /// </summary>
        public int Pages { get; set; }

        /// <summary>
        /// 当前页 = pageIndex
        /// </summary>
        public int Page { get; set; }

        /// <summary>
        /// 总记录数
        /// </summary>
        public int Total { get; set; }

        /// <summary>
        /// 总页数
        /// </summary>
        public int TotalPages
        {
            get
            {
                if (Pages == 0) return 0;
                return Total % Pages == 0 ? Total / Pages : Total / Pages + 1;
            }
            set { }
        }

        /// <summary>
        /// 下一页 没有则为null
        /// </summary>
        public int? NextPage
        {
            get
            {
                if (Page < Total) return Page + 1;
                return null;
            }
            set { }
        }

        /// <summary>
        /// 上一页 没有则为null
        /// </summary>
        public int? PrevPage
        {
            get
            {
                if (Page > 1) return Page - 1;
                return null;
            }
            set { }
        }

        public object Datas { get; set; }

        public IFilter Filter { get; set; }
    }
}
